{
Antonov_Kirill
19.09.2012.
this program is to find the sum of max and min numbers
}
program SecondNuber;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var
  i, j, n, min, max, s, t: integer;
  a: array of integer;
  fin: TextFile;

begin
  assignFile(fin, 'input.txt');
  reset(fin);
  readln(fin, n);
  setlength(a, n);
  for i:=0 to n-1 do
    read(fin, a[i]);
  for j:=0 to n-2 do
  begin
    s:=j;
    for i:=j+1 to n-1 do
    begin
      if (a[i] < a[s]) then
        s:=i;
    end;
    t:=a[j];
    a[j]:=a[s];
    a[s]:=t;
  end;
  writeln(a[0]+a[n-1]);
  readln
end.
 